各位邦友,既然程式經過「套件安裝」「測試」「打包」之後,再來就是要進行「佈署」的事情(Travis CI 佈署支援)。只要涉及服務跟服務之間要溝通運作。就要經過「授權」「設定」的過程。由於Travis CI 要透過.travis.yml
來跟「佈署提供者」互動。部份「設定」,要使用Travis CI Client來完成。
小編電腦是Windows
ruby -v
,確認安裝結果。
$ ruby -v
ruby 2.5.3p105 (2018-10-18 revision 65156) [x64-mingw32]
gem
安裝Travis CI Clienttravis version
$ gem install travis -v 1.8.9 --no-rdoc --no-ri
$ travis version
1.8.9
.travis.yml
deploy s3設定travis login --pro
$ travis login --pro
We need your GitHub login to identify you.
This information will not be sent to Travis CI, only to api.github.com.
The password will not be displayed.
Try running with --github-token or --auto if you don't want to enter your password anyway.
Username: bebright
Password for bebright: **************
Successfully logged in as bebright!
travis setup s3
$ travis setup s3
Access key ID: AKIAIA2J7HXUI52NHMHA
Secret access key: ****************************************
Bucket: bright-travis-deploy
Local project directory to upload (Optional): dist
S3 upload directory (Optional):
S3 ACL Settings (private, public_read, public_read_write,authenticated_read,
bucket_owner_read, bucket_owner_full_control): private
Encrypt secret access key? |yes|
Push only from bebright/slack-demo? |yes|
.travis.yml(新增設定)
deploy:
provider: s3
access_key_id: AKIAIA2J7HXUI52NHMHA
secret_access_key:
secure: JPDcEKISOrS4YK31WC...太長了(省略)
bucket: bright-travis-deploy
local-dir: dist
acl: private
on:
repo: bebright/slack-demo
skip_cleanup: true
:這一行真的很雷,不加的話,travis會把你build出來的東西清掉,搞超久的@@。
deploy:
# 同上
skip_cleanup: true
bright-travis-deploy
,建立步驟可參考這篇travis ci policy
,建立步驟可參考這篇 {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:DeleteObject",
"s3:DeleteObjectVersion",
"s3:GetBucketAcl",
"s3:GetObject",
"s3:GetObjectAcl",
"s3:GetObjectVersion",
"s3:GetObjectVersionAcl",
"s3:ListBucket",
"s3:PutObject",
"s3:PutObjectAcl",
"s3:PutObjectTagging"
],
"Resource": [
"arn:aws:s3:::bright-travis-deploy/*"
]
}
]
}
哇…今天「試」超~~~~~~久的…差點就在倒數第二天陣亡了。Orz
待續…